


clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user

set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"
 
clear all
set more off

cd "$path_data_processed"

use "experimentRNall.dta", clear

cd "$path_output"
 
set scheme lean2

reshape long cause_, i(rnid) j(id3) string


collapse (mean) cause_ (sd) sd=cause_ (count) n=cause_, by(id3)



drop if id3=="supply_num"
drop if id3=="demand_num"
drop if id3=="demand"
sort cause_


gen id2=1 if id3=="consumerconf"
replace id2=2 if id3=="political"
replace id2=3 if id3=="irates" 
replace id2=4 if id3=="stockmarket"  
replace id2=5 if id3=="terror"   
replace id2=6 if id3=="businessconf"
replace id2=7 if id3=="exports" 
replace id2=8 if id3=="oilprice" 
replace id2=9 if id3=="taxhikes" 
replace id2=10 if id3=="govspend" 
replace id2=11 if id3=="intermediateimports" 
replace id2=12 if id3=="commodities" 
replace id2=13 if id3=="naturaldisaster" 
replace id2=14 if id3=="housepricedrop" 
replace id2=15 if id3=="other" 
replace id2=16 if id3=="strikes" 


rename cause_ action

 set scheme lean2
gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Consumer confidence" 2 "Political turmoil" 3 "Interest rate hike" 4 "Stockmarket crash" 5 "Terror attack" 6 "Business confidence" 7 "Export demand" 8 "Oil price" 	9 "Tax hikes" 10 "Government spending" 11 "Import prices" 12 "Commodity prices" 13 "Natural disaster"  14 "House price drop" 15 "Other" 16 "Strikes", noticks labsize(*0.8) angle(45) ) ///	
	xtitle("Three most likely recession causes", size(*0.75)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
		name(recession_causes, replace)	
	   graph display recession_causes, xsize(20) ysize(10)
				graph export "recession_causes.pdf", replace
		graph save "recession_causes.gph", replace

********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************		


 cd "$path_data_processed"

 
 use "experimentRNall.dta", clear

cd "$path_output"
 
set scheme lean2

reshape long cause_, i(rnid) j(id3) string


collapse (mean) cause_ (sd) sd=cause_ (count) n=cause_, by(id3)



drop if id3=="supply_num"
drop if id3=="demand_num"
drop if id3=="demand"
sort cause_


gen id2=1 if id3=="consumerconf"
replace id2=2 if id3=="political"
replace id2=3 if id3=="irates" 
replace id2=4 if id3=="stockmarket"  
replace id2=5 if id3=="terror"   
replace id2=6 if id3=="businessconf"
replace id2=7 if id3=="exports" 
replace id2=8 if id3=="oilprice" 
replace id2=9 if id3=="taxhikes" 
replace id2=10 if id3=="govspend" 
replace id2=11 if id3=="intermediateimports" 
replace id2=12 if id3=="commodities" 
replace id2=13 if id3=="naturaldisaster" 
replace id2=14 if id3=="housepricedrop" 
replace id2=15 if id3=="other" 
replace id2=16 if id3=="strikes" 


rename cause_ action

 set scheme lean2
gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Consumer confidence" 2 "Political turmoil" 3 "Interest rate hike" 4 "Stockmarket crash" 5 "Terror attack" 6 "Business confidence" 7 "Export demand" 8 "Oil price" 	9 "Tax hikes" 10 "Government spending" 11 "Import prices" 12 "Commodity prices" 13 "Natural disaster"  14 "House price drop" 15 "Other" 16 "Strikes", noticks labsize(*0.8) angle(45) ) ///	
	xtitle("Three most likely recession causes: sample with low education", size(*0.75)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
		name(recession_causes, replace)	
	   graph display recession_causes, xsize(20) ysize(10)
				graph export "recession_causes_loweduc.pdf", replace
		graph save "recession_causes_loweduc.gph", replace




********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************		


 cd "$path_data_processed"

 use "experimentRNall.dta", clear

cd "$path_output"
 
set scheme lean2

reshape long cause_, i(rnid) j(id3) string


collapse (mean) cause_ (sd) sd=cause_ (count) n=cause_, by(id3)



drop if id3=="supply_num"
drop if id3=="demand_num"
drop if id3=="demand"
sort cause_


gen id2=1 if id3=="consumerconf"
replace id2=2 if id3=="political"
replace id2=3 if id3=="irates" 
replace id2=4 if id3=="stockmarket"  
replace id2=5 if id3=="terror"   
replace id2=6 if id3=="businessconf" 
replace id2=7 if id3=="exports" 
replace id2=8 if id3=="oilprice" 
replace id2=9 if id3=="taxhikes" 
replace id2=10 if id3=="govspend" 
replace id2=11 if id3=="intermediateimports" 
replace id2=12 if id3=="commodities" 
replace id2=13 if id3=="naturaldisaster" 
replace id2=14 if id3=="housepricedrop" 
replace id2=15 if id3=="other" 
replace id2=16 if id3=="strikes" 


rename cause_ action

 set scheme lean2
gen standarderror = invttail(n-1,0.025)*(sd / sqrt(n))


generate hiz_avg = action + 1*(standarderror)
generate lowz_avg = action - 1*(standarderror)
 
 
gen zero=0
 
   twoway    (rbar action zero id2)   (rcap hiz_avg lowz_avg id2 ),  legend(off) ///
 ylabel(0.2(0.1)0.5) ///
	xlabel( 1 "Consumer confidence" 2 "Political turmoil" 3 "Interest rate hike" 4 "Stockmarket crash" 5 "Terror attack" 6 "Business confidence" 7 "Export demand" 8 "Oil price" 	9 "Tax hikes" 10 "Government spending" 11 "Import prices" 12 "Commodity prices" 13 "Natural disaster"  14 "House price drop" 15 "Other" 16 "Strikes", noticks labsize(*0.8) angle(45) ) ///	
	xtitle("Three most likely recession causes: sample with high education", size(*0.75)) ///
	ytitle("Mean {&plusmn} s.e.m.") ///	  
		name(recession_causes_higheduc, replace)	
	   graph display recession_causes_higheduc, xsize(20) ysize(10)
				graph export "recession_causes_higheduc.pdf", replace
		graph save "recession_causes_higheduc.gph", replace





